package beans;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;
import org.springframework.beans.factory.config.BeanPostProcessor;

/**
 * @auther hewenhui
 * @see <a href="hetp://www.codingmaster.com> java </a>
 */
public class User implements BeanNameAware, BeanClassLoaderAware, BeanFactoryAware, InitializingBean, DisposableBean {
    private String name;

    public User() {
        System.out.println("1.实例化Bean");
    }

    public void setName(String name) {
        this.name = name;
        System.out.println("2.Bean属性赋值");
    }


    //他每一步都有存在的意义啊！ininBean的意义是啥？
    public void initBean(){
        System.out.println("3.初始化Bean");
    }

    public void destroyBean(){
        System.out.println("5.销毁Bean");
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                '}';
    }


    @Override
    public void setBeanClassLoader(ClassLoader classLoader) {
        System.out.println("十（1）类加载器"+classLoader);

    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("十（1）Bean工厂"+beanFactory);

    }

    @Override
    public void setBeanName(String name) {
        System.out.println("十（1）bean名字"+name);
    }



    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("十（2） afterPropertiesSet执行");
    }





    @Override
    public void destroy() throws Exception {
        System.out.println("十（3）DisposableBean destroy");
    }
}
